/**
 * 
 */
package app.util;

import static app.constants.CollabVizConstants.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;

import core.proto.Util;

import app.constants.CollabVizConstants;
import app.exceptions.CollabVizException;

public final class PropertyLoaderUtil {

	/**
	 * Represents the settings loaded from the config file. 
	 */
	private static Properties prop;

	// Load from config file. 
	static{
		prop = new Properties();
//		try {
////			String configFilePath = CONFIG_FILE_NAME;
////			//String configFilePath = FilenameUtils.concat(System.getProperty("user.dir"), CONFIG_FILE_NAME);
////			prop.load(new FileInputStream(new File(configFilePath)));
//		} catch (FileNotFoundException e) {
//			//throw new Error("Config file not found at " + FilenameUtils.concat(System.getProperty("user.dir"), CONFIG_FILE_NAME));
//		} catch (IOException e) {
//			throw new Error(e);
//		}
	}
	
	/**
	 * Value look up. 
	 * @param key
	 * @return
	 * @throws CollabVizException
	 */
	public static String getProp(String key) throws CollabVizException {
		String result = null;
		if (key == null || StringUtils.isEmpty(key)) {
			throw new CollabVizException(
					CollabVizConstants.INCOMING_PARAM_EMPTY_ERROR);
		}
		if (prop != null) {
			result = (String) prop.get(key);
		}
		return result;
	}
}
